<?php
	function search_prod ($catno) {
		$product = "";
		$cate = "";
		$tblno = '0';
		$tbl = '0';
		$path = '0';
		$catno = $catno;
		
		
		$sno=array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','30');
		foreach ($sno as $value){
			$dbno=$value;
			
			switch ($dbno) {
				
				//search antibodies
				case "1" :
					include ('conn.php');
					$sql="select * from products where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'products';
						$path = "conn.php";
						$catName = "Antibodies";
					}
					break;
					
				//search siRNA
				case "2" :
					include ('conn.php');
					$sql="select * from prodsirna where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodsirna';
						$path = "conn.php";
						$catName = "Pre-Made siRNA";
					}
					break;
					
				//search Lentivirus
				case "3" :
					include ('conn.php');
					$sql="select * from prodlenti where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodlenti';
						$path = "conn.php";
						$catName = "Pre-Made Lentivirus";
					}
					break;
					
				//search Adenovirus
				case "4" :
					include ('conn.php');
					$sql="select * from prodadenovirus where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodadenovirus';
						$path = "conn.php";
						$catName = "Pre-Made Adenovirus";
					}
					break;
					
				//search PCR
				case "5" :
					include ('conn.php');
					$sql="select * from prodpcr where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodpcr';
						$path = "conn.php";
						$catName = "RT/PCR/qPCR";
					}
					break;
					
				//search Transfections
				case "6" :
					include ('conn.php');
					$sql="select * from prodtrans where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodtrans';
						$path = "conn.php";
						$catName = "Transfection";
					}
					break;
					
				//search Second Antibodies
				case "8" :
					include ('conn.php');
					$sql="select * from prodsecondanti where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodsecondanti';
						$path = "conn.php";
						$catName = "Secondary Antibodies";
					}
					break;
					
				//search RNA
				case "9" :
					include ('conn.php');
					$sql="select * from prodrna where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodrna';
						$path = "conn.php";
						$catName = "siRNA";
					}
					break;
					
				//search Immortalized Primary Cells
				case "18" :
					include ('conn.php');
					$sql="select * from prodihc where catNo like '$catno'";
					$result = mysql_query($sql,$db);
					$row = mysql_num_rows($result);
					if ($row > 0){
						$tblno = $dbno;
						$tbl = 'prodihc';
						$path = "conn.php";
						$catName = "Immortalized Primary Cells";
					}
					break;
				
				
				default: 
					//search other exceptions
					switch ($dbno){
						case "7":
							$catName="Viral Expression";
							break;
						case "9":
							$catName="Tag Antibodies";
							break;
						case "10":
							$catName="Loading Controls";
							break;
						case "12":
							$catName="Cell Lysates";
							break;
						case "13":
							$catName="Cell Immortalization";
							break;
						case "14":
							$catName="DNA purification";
							break;
						case "15":
							$catName="Western Blot";
							break;
						case "16":
							$catName="DNA Marker and Chemicals";
							break;
						case "17":
							$catName="Sample Preparation";
							break;
					}
					
					if ($dbno == '9' || $dbno =='10'){//search old database for Tag Antibody and loading control products
						include ('connabm.php');
						$sql="select * from products where catNo like '$catno'";
						$result = mysql_query($sql,$db);
						$row = mysql_num_rows($result);
						if ($row > 0){
							$tblno = $dbno;
							$tbl = 'products';
							$path = "connabm.php";
						}
					}else{
						include ('conn.php');
						$sql="select * from prodothers where catNo like '$catno'";
						$result = mysql_query($sql,$db);
						$row = mysql_num_rows($result);
						if ($row > 0){
							$tblno = $dbno;
							$tbl = 'prodothers';
							$path = "conn.php";
						}
					}
			}
		}
		return array('tblno'=>$tblno,'tbl'=>$tbl,'path'=>$path);
	}
?>